import { NgModule } from '@angular/core'
import { Routes, RouterModule, ExtraOptions } from '@angular/router'
import { HomeComponent } from './home/home.component'
import { CollectionsComponent } from './collections/collections.component'
import { BlockchainComponent } from './blockchain/blockchain.component'
import { AuthGuardService } from './@core/auth-guard-service.guard'
import { LoginComponent } from './login/login.component'
import { RegisterComponent } from './login/register/register.component'
import { LoginsComponent } from './login/logins/logins.component'
import { ManageComponent } from './manage/manage.component'
import { CollectionComponent } from './manage/collection/collection.component'
import { MintComponent } from './manage/mint/mint.component'
import { UserManageComponent } from './manage/user-manage/user-manage.component'
import { BaseUserInfoComponent } from './base-user-info/base-user-info.component'
import { UserVerificationComponent } from './user-verification/user-verification.component'
import { SpareComponent } from './@shared/components/spare/spare.component'
import { MsgLoginComponent } from './login/msg-login/msg-login.component'
import { RegisterSuccessComponent } from './login/register-success/register-success.component'
import { AvatarDetailComponent } from './collections/avatar-detail/avatar-detail.component'
import { OrderManageComponent } from './order-manage/order-manage.component'
import { AccountComponent } from './base-user-info/account/account.component'
import { PasswordComponent } from './base-user-info/password/password.component'
import { PhoneConnectComponent } from './base-user-info/phone-connect/phone-connect.component'
import { MarketComponent } from './market/market.component'
const routes: Routes = [
  {
    path: 'home',
    component: HomeComponent,
    data: { navType: 1 },
    canActivate: [AuthGuardService]
  },
  {
    path: 'market',
    component: MarketComponent,
    data: { navType: 2, navTitle: '藏品市场' },
  },
  {
    path: 'collections',
    data: { navType: 2, navTitle: '我的藏品' },
    component: CollectionsComponent,
    canActivate: [AuthGuardService]
  },
  {
    path: 'collections/collection',
    data: { navType: 2, navTitle: '我的藏品' },
    component: AvatarDetailComponent,
    canActivate: [AuthGuardService]
  },
  {
    path: 'blockchain',
    component: BlockchainComponent,
    canActivate: [AuthGuardService]
  },
  {
    path: 'userVerification',
    data: { navType: 2, navTitle: '通行证' },
    component: UserVerificationComponent,
    canActivate: [AuthGuardService]
  },
  {
    path: 'baseUserInfo/passwordModify',
    data: { navType: 2, navTitle: '个人中心' },
    component: PasswordComponent,
    canActivate: [AuthGuardService],
  },
  {
    path: 'baseUserInfo',
    data: { navType: 2, navTitle: '个人中心' },
    component: BaseUserInfoComponent,
    canActivate: [AuthGuardService],
  },
  {
    path: 'baseUserInfo/passwordModify',
    data: { navType: 2, navTitle: '个人中心' },
    component: PasswordComponent,
    canActivate: [AuthGuardService]
  },
  {
    path: 'baseUserInfo/telephoneConnect',
    data: { navType: 2, navTitle: '个人中心' },
    component: PhoneConnectComponent,
    canActivate: [AuthGuardService]
  },
  {
    path: 'baseUserInfo/logoff',
    data: { navType: 2, navTitle: '个人中心' },
    component: AccountComponent,
    canActivate: [AuthGuardService]
  },
  {
    path: 'orderManage',
    data: { navType: 2, navTitle: '订单中心' },
    component: OrderManageComponent,
    canActivate: [AuthGuardService],
  },
  {
    path: 'register',
    component: RegisterComponent,
    canActivate: [AuthGuardService],
    data: { navType: 2, navTitle: '通行证' },
  },
  {
    path: 'register/success',
    component: RegisterSuccessComponent,
    canActivate: [AuthGuardService],
    data: { navType: 2, navTitle: '通行证' },
  },
  {
    path: 'login',
    component: LoginComponent,
    data: { navType: 2, navTitle: '通行证' },
    children: [
      {
        path: 'msgLogin',
        component: MsgLoginComponent,
        canActivate: [AuthGuardService],
      },
      {
        path: 'logins',
        component: LoginsComponent,
        canActivate: [AuthGuardService],
      }
    ]
  },
  {
    path: 'manage',
    component: ManageComponent,
    data: { navType: 2, navTitle: '管理系统' },
    canActivate: [AuthGuardService],
    children: [
      {
        path: 'collection',
        component: CollectionComponent
      },
      {
        path: 'mint',
        component: MintComponent
      },
      {
        path: 'userManage',
        component: UserManageComponent
      }
    ]
  },
  {
    path: 'spare',
    component: SpareComponent
  },
  { path: '', redirectTo: 'home', pathMatch: 'full' },
  { path: '**', redirectTo: 'home', pathMatch: 'full' }
]

const config: ExtraOptions = {
  useHash: false
}

@NgModule({
  imports: [RouterModule.forRoot(routes, config)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
